﻿namespace Tnelab.WebAppTestBLL
{
    public class TestService
    {
        public List<List<SayNameInfo>> ListTest(bool flag, List<List<SayNameInfo>> list, string test)
        {
            if (flag != true || test != "Js ListTest测试")
                throw new Exception("ListTest测试异常");
            return list;
        }
        public SayNameInfo[] ArrayTest(int x, SayNameInfo[] sayNameInfos, string test)
        {
            if (x != 100 || test != "Js ArrayTest测试")
                throw new Exception("ArrayTest测试异常");
            return sayNameInfos;
        }
        public void NoneTest()
        {
        }
        public string NullTest(string nil)
        {
            if (nil != null)
                throw new Exception("NullTest测试异常");
            return nil;
        }
        public string NoneStringTest(string msg)
        {
            if (msg != "")
                throw new Exception("NoneStringTest测试异常");
            return msg;
        }
        public SayNameInfo EntityTest(int x, SayNameInfo sayNameInfo, int y)
        {
            if (x != 100 || y != 200 || sayNameInfo.Index != 1 || sayNameInfo.Name != "Esrin测试1")
                throw new Exception("EntityTest测试异常");
            return sayNameInfo;
        }
        public double BaseTest(Int16 a, UInt16 b, int x, uint y, bool b1, byte be, bool b2, sbyte sbe, double d, float f, string str)
        {
            if (a != -200 || b != 200 || x != -300 || y != 300 || b1 != true || be != 255 || b2 != false || sbe != -120 || d != 1.2 || f != 1.3f || str != "BaseTest测试")
                throw new Exception("BaseTest测试异常");
            return d;
        }
        public byte[] FuncTest(Func<string, string> func, byte[] theBytes, string msg)
        {
            var rmsg = func(msg);
            return theBytes;
        }
        public byte[] FuncTest2(Func<string> func, byte[] theBytes, string msg)
        {
            var rmsg = func();
            return theBytes;
        }
        public byte[] ActionTest(Action<short, ushort, int, uint, bool, byte, bool, sbyte, double, float, string> action, string str, byte[] bytes)
        {
            if (str != "ActionTest测试")
                throw new Exception("ActionTest测试异常");
            action(-200, 200, -300, 300, true, 255, false, -120, 1.2, 1.3f, "ActionTest测试");

            return bytes;
        }
        public byte[] ActionTest2(Action action, string str, byte[] bytes)
        {
            if (str != "ActionTest2测试")
                throw new Exception("ActionTest2测试异常");
            action();

            return bytes;
        }
        public string DevFunc(Func<string, string> func, string msg)
        {
            //Task.Run(() => {
            //    Thread.Sleep(2000);
            //    for (var i = 0; i < 100; i++)
            //    {
            //        var r=func(msg);
            //    }
            //});            
            //return "cs deb func";
            var result= func(msg);
            return result;
        }
    }
}